<template>
  <!-- 价格提示 -->
  <div>
    <!-- 表格 -->
    <FilterTable
      ref="table"
      :onRowSelectChange="arr => (this.onChangeColumn = arr)"
      :onColumnsChange="columns => (this.columns = columns)"
      :columns="columns"
      columnsRef="jiaGeTiShiPart"
      :dataSource="this.dataIn"
      height="auto"
      :datakey="'rows'"
    ></FilterTable>
    <div class="btnWrap">
      <el-button @click="$emit('cancel')">取 消</el-button>
      <el-button type="primary" @click="confirmBtnClick">同步R3主文件</el-button>
    </div>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { notifyAction } from '@/utils';

export default {
  name: 'cgrk_part_search',
  mixins: [dictionary],
  props: ['dataIn'],
  data() {
    return {
      onChangeColumn: [],
      columns: this.createColumns()
    };
  },
  methods: {
    confirmBtnClick() {
      if (this.onChangeColumn.length) {
        this.$emit('confirm', this.onChangeColumn);
      } else {
        notifyAction('请选择需要更新价格的行项', 'warning');
      }
    },
    createColumns() {
      return [
        // 序号
        {
          title: '序号',
          width: 70,
          dataIndex: 'xuhao',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          },
          sorter: true
        },
        // 配件代码
        {
          title: 'PART_NO',
          width: 100,
          showOverflowTooltip: true,
          dataIndex: 'partNo',
          filter: true,
          filterType: 'input'
        },
        // 配件名称
        {
          title: '配件名称',
          width: 100,
          showOverflowTooltip: true,
          dataIndex: 'partName',
          filter: true,
          filterType: 'input'
        },
        // 采购单价
        {
          title: '采购单价',
          sorter: true,
          dataIndex: 'inPrice',
          filter: true,
          precision: 2,
          filterType: 'number'
        },
        // EP主文件采购单价
        {
          title: 'EP主文件采购单价',
          sorter: true,
          dataIndex: 'EP_IN_PRICE',
          filter: true,
          filterType: 'number',
          precision: 2
        },
        // r3采购价
        {
          title: 'r3采购价',
          sorter: true,
          dataIndex: 'KBETR',
          filter: true,
          precision: 2,
          filterType: 'number'
        }
      ];
    }
  }
};
</script>

<style scoped>
.btnWrap {
  position: absolute;
  left: 0px;
  bottom: 0px;
  right: 0px;
  z-index: 9;
  border-top: 1px solid rgb(233, 233, 233);
  padding: 10px 20px;
  background: rgb(255, 255, 255);
  text-align: right;
}
</style>
